<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.lmpop.frame.util.PageTools"%>
<%@ page import="com.lmpop.frame.util.Config"%>
<%@page import="com.lmpop.trade.ti_teamorder.Ti_groupVoucherInfo"%>
<%
	request.setCharacterEncoding("UTF-8");
	Ti_groupVoucherInfo groupVoucherInfo = new Ti_groupVoucherInfo();
	Map params = new Hashtable();

	String _voucher_code = "", user_id = "",_enabled="";
	if (request.getParameter("voucher_code") != null
			&& !request.getParameter("voucher_code").equals("")) {
		_voucher_code = request.getParameter("voucher_code");
		params.put("voucher_code", _voucher_code);
	}
	if (request.getParameter("enabled") != null
			&& !request.getParameter("enabled").equals("")) {
		_enabled = request.getParameter("enabled");
		params.put("enabled", _enabled);
	}
	
	params.put("user_id",_user_id);
	String iStart = "0";
	int counter = 0;
	List list = null;
	int limit = 5;
	if (request.getParameter("iStart") != null)
		iStart = request.getParameter("iStart");

	counter = groupVoucherInfo.getCountByObj(params);
	list = groupVoucherInfo.getListByPage(params, Integer
			.parseInt(iStart), limit);

	String pageString = new PageTools().getGoogleToolsBar(counter,
			"index.jsp?voucher_code=" + _voucher_code + "&enabled="+_enabled+"&iStart=",
			Integer.parseInt(iStart), limit);
%>
<html>
	<head>
		<title>徽诚券管理</title>
		<link href="/program/admin/index/css/style.css" rel="stylesheet"
			type="text/css">
		<script language="javascript" type="text/javascript"
			src="/program/plugins/calendar/WdatePicker.js"></script>
		<script type="text/javascript" src="/js/jquery.js"></script>
	</head>
	<body>
		<div>

			<form action="index.jsp" name="voucherForm" method="post">

				<table width="100%" border="0" cellspacing="0" cellpadding="0" class="dl_su">

					<tr>

						<td>
							<table width="100%" border="0" cellpadding="0" cellspacing="0">

								<tr>

									<td width="5%" height="40" align="center">
										<img src="/program/member/index/images/icon1.gif">
									</td>

									<td width="85%">
										<h3>
											我的徽诚券
										</h3>
									</td>

								</tr>

							</table>

							<table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr>
									<td height="30" align="left">
										券号:
										<input type="text" class="input" name="voucher_code"
											id="voucher_code" maxlength="50" />
										状态:
										<select id="o_order_state" name="enabled">
											<option value="">
												请选择
											</option>
											<option value="1">
												未使用
											</option>
											<option value="0">
												已使用
											</option>
										</select>

										<input type="button" name="Submit" value="搜索"
											onclick="document.voucherForm.submit();" class="button2" />
									</td>

								</tr>
							</table>

							<table width="100%"  cellspacing="1"
								cellpadding="1" border="0">
								<tr>

									<th width="120">
										券号
									</th>

									<th width="50">
										密码
									</th>

									<th width="50">
										生成时间
									</th>

									<th width="100">
										当前状态
									</th>

									<th width="50">
										操作
									</th>
								</tr>


								<%
									String team_path = "/data/teambuy/";
									String teambuyurl = "";
									int listsize = 0;
									Hashtable nMap = new Hashtable();
									List goodslist = new ArrayList();
									if (null != list && list.size() > 0) {
										listsize = list.size();
										for (int i = 0; i < list.size(); i++) {
											nMap = (Hashtable) list.get(i);
											String order_no = "", in_date = "", enabled = "", tip = "", info_id = "", voucher_code = "", voucher_pwd = "";
											if (nMap.get("order_no") != null)
												order_no = nMap.get("order_no").toString();
											if (nMap.get("in_date") != null){
												in_date = nMap.get("in_date").toString();
												in_date=in_date.substring(0,19);
											}
											if (nMap.get("enabled") != null)
												enabled = nMap.get("enabled").toString();
											if (nMap.get("info_id") != null)
												info_id = nMap.get("info_id").toString();
											if (nMap.get("tip") != null)
												tip = nMap.get("tip").toString();
											if (tip.length() > 100)
												tip = tip.substring(0, 100);
											if (nMap.get("voucher_code") != null)
												voucher_code = nMap.get("voucher_code").toString();
											if (nMap.get("voucher_pwd") != null)
												voucher_pwd = nMap.get("voucher_pwd").toString();
								%>
								<tr>
									<td width="70">
										<%=voucher_code%>
									</td>
									<td width="70">
										<%=voucher_pwd%>
									</td>
									<td width="70">
										<%=in_date%>
									</td>
									<td width="70">
										<%
											if (enabled.equals("1"))
														out.println("未使用");
										%>
										<%
											if (enabled.equals("0"))
														out.println("已使用");
										%>
									</td>
									<td width="70">
										<a href="#" onclick="window.print();">打印</a>
									</td>
								</tr>

								<%
									}
									}
								%>
							</table>


							<table width="100%" border="0" cellpadding="0" cellspacing="0">
								<tr>
									<td width="4%" height="35" align="center">
										<%=pageString%>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>


			</form>
		</div>
	</body>
</html>